package whlogger.launcher.loginfields.views.repositories;

import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import whlogger.launcher.loginfields.views.behavior.LoginJButtonBehavior;
import whlogger.launcher.loginfields.views.behavior.NicknameJTextFieldBehavior;
import whlogger.launcher.loginfields.views.behavior.PasswordJPasswordFieldBehavior;

/**
 *
 * @author d3rbastl3r
 */
public class BehaviorRepository {
    private NicknameJTextFieldBehavior nicknameBehavior = null;
    private PasswordJPasswordFieldBehavior passwordBehavior = null;
	private LoginJButtonBehavior loginBehavior = null;
    
    public BehaviorRepository(){
    }
    
    public NicknameJTextFieldBehavior getNicknameBehavior(){
        return this.nicknameBehavior;
    }
    
    public void initNicknameBehavior(JTextField component){
        this.nicknameBehavior = new NicknameJTextFieldBehavior(component);
    }
    
    public PasswordJPasswordFieldBehavior getPasswordBehavior(){
        return this.passwordBehavior;
    }
    
    public void initPasswordBehavior(JPasswordField component){
        this.passwordBehavior = new PasswordJPasswordFieldBehavior(component);
    }
	
	public LoginJButtonBehavior getLoginBehavior(){
        return this.loginBehavior;
    }
    
	/**
	 * Setzt voraus, dass nicknameBehavior und passwordBehavior bereits
	 * gesetzt sind.
	 * @param component 
	 */
    public void initLoginBehavior(JButton component){
        this.loginBehavior = new LoginJButtonBehavior(component, this);
		this.nicknameBehavior.addPropertyChangeListener(this.loginBehavior);
		this.passwordBehavior.addPropertyChangeListener(this.loginBehavior);
    }
}
